﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Obligatorio.DataAccess;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ProductosProvistos : System.Web.Services.WebService {

    public ProductosProvistos () {
    }

    [WebMethod]
    public string obtenerProductos(string branchId, string date, string providerId, string user, string pass) {
        using (ObligatorioDotNetEntities data = new ObligatorioDotNetEntities())
        {
            List<SP_GetProductsByBranchDate_Result> productos = data.SP_GetProductsByBranchDate(short.Parse(providerId), short.Parse(branchId), DateTime.Parse(date), user, Utils.GetMD5(pass)).ToList();

            if (productos != null)
            {
                System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                new System.Web.Script.Serialization.JavaScriptSerializer();
                return oSerializer.Serialize(productos);
            }

            return "";
        }
    }
    
}
